
package com.android.finaltracer.usermanage;

import android.content.Context;

import com.android.finaltracer.channel.ChannelProxy;
import com.android.finaltracer.engine.EventNotify;

public class Phone {
    public static final int PHONE_STATUS_NULL = 1;// 1
    private String phoneNum;
    private int phoneStatus;
    protected Context mContext;
    protected ChannelProxy mChannelProxy;
    protected long GPS_TRACER_HEART_BEAT = 60 * 1000;
    protected int retryCount = 0;
    protected int maxRetryCount = 3;

    private Phone(String phoneNum, int phoneStatus) {
        super();
        this.phoneNum = phoneNum;
        this.phoneStatus = phoneStatus;
    }

    public Phone(String phoneNum, Context mContext, EventNotify mEventNotify) {
        this(phoneNum);
        this.mContext = mContext;
        mChannelProxy = ChannelProxy.getInstance(mContext, mEventNotify);
    }

    private Phone(String phoneNum) {
        this(phoneNum, PHONE_STATUS_NULL);
    }

    public void reInit() {
        phoneStatus = PHONE_STATUS_NULL;
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public int getPhoneStatus() {
        return phoneStatus;
    }

    public void setPhoneStatus(int phoneStatus) {
        this.phoneStatus = phoneStatus;
    }

    public boolean isSamePhone(String phoneNumber) {

        String privateNum = this.phoneNum;
        String secodaryNum = phoneNumber;

        if (secodaryNum.charAt(0) == '+') {
            secodaryNum = secodaryNum.substring(3);
        }
        if (privateNum.charAt(0) == '+') {
            privateNum = privateNum.substring(3);
        }
        if (secodaryNum.equals(privateNum)) {
            return true;
        } else {
            return false;
        }
    }

    public void clearRetryCount() {
        retryCount = 0;
    }

    public boolean isOutRetry() {
        return retryCount >= maxRetryCount;
    }
}
